//
//  MCChangeCommunityCell.swift
//  StoreManage
//
//  Created by MC on 2018/7/3.
//  Copyright © 2018年 MC. All rights reserved.
//

import UIKit


class MCChangeCommunityCell: UITableViewCell {
    
    
    var model = MCCommunityModel() {
        didSet {
            nameLabel.text = model.communityName
            addressLabel.text = model.province + model.city + model.area + model.address
            statusButton.isSelected = model.isSelected
        }
    }
    
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        self.addSubview(bgView)
        bgView.snp.remakeConstraints { (make) ->Void in
            make.edges.equalTo(self).inset(UIEdgeInsetsMake(0, 0, 1, 0))
        }
        
        bgView.addSubview(statusButton)
        statusButton.snp.remakeConstraints { (make) ->Void in
            make.right.equalTo(-15)
            make.centerY.equalTo(bgView)
            make.size.equalTo(CGSize.init(width: 20, height: 20))
        }

        
        bgView.addSubview(nameLabel)
        nameLabel.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(15)
            make.right.equalTo(statusButton.snp.left).offset(-10)
            make.bottom.equalTo(bgView.snp.centerY).offset(-2)
        }
        
        
        bgView.addSubview(addressLabel)
        addressLabel.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(15)
            make.right.equalTo(statusButton.snp.left).offset(-10)
            make.top.equalTo(bgView.snp.centerY).offset(3)
        }

        
        

    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    

    lazy var bgView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.white
        return view
    }()
    
    lazy var nameLabel: MCLabel = {
        let label = MCLabel()
        label.font = UIFont.boldSystemFont(ofSize: 15)
        return label
    }()
    
    lazy var addressLabel: MCLabel = {
        let label = MCLabel()
        label.font = MCFont(14)
        label.numberOfLines = 0
        return label
    }()
    
    
    lazy var statusButton: UIButton = {
        let button = UIButton.init(type: UIButtonType.custom)
        button.setImage(#imageLiteral(resourceName: "Reuse_selected"), for: .normal)
        button.setImage(#imageLiteral(resourceName: "Reuse_selectedSign"), for: .selected)
        return button
    }()
    
}
